This repository was archived by the owner on Jul 19, 2025. It is now read-only.
Configure different mass thresholds for identical & similar issues #47
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of the things I've noticed recently when running the duplication engine both against real code & just for testing is that generally when it emits issues I think are silly, it's because the the locations are structurally similar, but not identical. Examples of kind of silly issues this results in:
attributes
macro with two completely different sets of attribute names on two separate classes (i.e.attribute :foo, :bar, :baz
is a duplicate ofattribute :fleek, :fluck, :fark
)if (this.someProp) { a.doThing(); b.doAlso(); } else { a.doOtherThing(); b.doOtherAlso(); }
)I'm of the opinion that generally speaking the bar for similar code being a violation should be higher than identical code. Particularly at relatively low masses (which our defaults all are). Complaining about things like calling methods with different arguments in different places is not just low-value, but negative value IMHO: it's noise that distracts from legitimate issues & makes the engine as a whole seem less reliable.
This won't completely eliminate these instances, but it will make them rarer & easier to filter out without throwing out the baby with the bathwater (the baby in this case being more severe duplication issues that are either identical blocks or bigger similar blocks). I'm also starting to think setting per-file/global levels would also be helpful: i.e. you might want a lower threshold for similar code in the same file than you do for similar code across an entire project.
Thoughts, @codeclimate/review ?